package com.lei.test;

import com.alibaba.druid.pool.DruidDataSource;

import com.alibaba.druid.pool.DruidPooledConnection;

import org.junit.jupiter.api.Test;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.ResourceBundle;

public class testDruid {
    @Test
    public void Test() throws SQLException {
        DruidDataSource source = new DruidDataSource();
        source.setDriverClassName("com.mysql.jdbc.Driver");
        source.setUrl("jdbc:mysql://localhost:3306/mysql");
        source.setUsername("root");
        source.setPassword("admin");
        Connection connection = source.getConnection();
        System.out.println(connection);

    }
    @Test
    public void Test01() throws SQLException {
        ResourceBundle re=ResourceBundle.getBundle("jdbc");
        DruidDataSource druidDataSource = new DruidDataSource();
        druidDataSource.setDriverClassName(re.getString("jdbc.driver"));
        druidDataSource.setUrl(re.getString("jdbc.url"));
        druidDataSource.setUsername(re.getString("jdbc.username"));
        druidDataSource.setPassword(re.getString("jdbc.password"));
        DruidPooledConnection connection = druidDataSource.getConnection();
        System.out.printf("Druid连接"+connection);
    }
}
